------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure4.log
  log type:  text
 opened on:  30 Mar 2017, 13:56:06

. set more off

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      africancabinets_figure4.do                      *;
. *       Date:           January 3, 2017                                 *;
. *       Author:         Molly Ariotti and Sona Golder                   *;
. *       Purpose:        Produce Figure 4 for CPS African portfolio      *;
. *                       allocation paper.                               *;
. *           Input File:     tmp3.dta which is from Francois, Rainer, and    *;
. *                       Trebbi 2015 Econometrica                        *;
. *       Output File:    figure4.log, ethnic.eps                         *;
. *       Data Output:    none                                            *;
.              *       Previous file:  none                                            *;
. *       Machine:        laptop                                                          *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "\Users\sgolder\Dropbox\Portfolio Allocation\replication\tmp3.dta";

.  sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     country |          0
   month_gov |     11,749    6.803473     2.34425          1         12
    year_gov |     11,749     1982.97    12.76563       1960       2004
 ethnicgroup |          0
    longname |          0
-------------+---------------------------------------------------------
    popshare |     11,749    .0543876    .0624053       .004        .39
 leadergroup |     11,749    .0612818    .2398567          0          1
     govsize |     11,749    25.79002    9.363562          8         60
govpositions |     11,749    1.371521     2.13291          0         20
    govshare |     11,749    .0541041    .0831472          0   .8823529
-------------+---------------------------------------------------------
  topgovsize |     11,749    8.863648    3.226781          1         19
topgovposi~s |     11,749    .4643799    .9204414          0        8.5
lowgovposi~s |     11,749     .907141    1.526737          0         17
 topgovshare |     11,749    .0542302    .1099001          0          1
 lowgovshare |     11,749    5.398706    8.559959          0   86.36364
-------------+---------------------------------------------------------
leadertran~n |     11,749    .1034131    .3045106          0          1
cabtransit~n |     11,470    .1833479    .3869683          0          1
   stayshare |     11,470    .7190719     .278442          0          1
topstayshare |     11,470    .7460053    .2915855          0          1
  lowgovsize |     11,749    16.92638     8.65562          3         51
-------------+---------------------------------------------------------
         cid |     11,749    331.8315    197.7827          1        639
proportion~y |     11,749    1.090032    1.844176          0         30
norepresen~n |     11,749     .447953    .4973049          0          1
largestgroup |     11,749    .0580475    .2338432          0          1
          id |     11,749    8.215593     4.61433          1         15
-------------+---------------------------------------------------------
         idd |     11,749    139.2933    80.62927          1        279
   popshare2 |     11,749    .0068521    .0171878    .000016      .1521
coalitionm~r |     11,749     .552047    .4973049          0          1

.  desc;

Contains data from \Users\sgolder\Dropbox\Portfolio Allocation\replication\tmp3.dta
  obs:        11,749                          
 vars:            28                          18 Dec 2013 12:37
 size:     2,420,294                          
------------------------------------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
------------------------------------------------------------------------------------------------------------------
country         str17   %17s                  Country
month_gov       byte    %8.0g                 Month_Gov
year_gov        float   %8.0g                 Year_Gov
ethnicgroup     str20   %20s                  
longname        str60   %60s                  Long name
popshare        float   %8.0g                 
leadergroup     double  %9.0g                 (sum) leadergroup
govsize         float   %9.0g                 
govpositions    double  %9.0g                 (sum) ethniccabinet
govshare        float   %9.0g                 
topgovsize      float   %9.0g                 
topgovpositions double  %9.0g                 (sum) ethniccabinet
lowgovpositions float   %9.0g                 
topgovshare     float   %9.0g                 
lowgovshare     float   %9.0g                 
leadertransit~n float   %9.0g                 
cabtransition   float   %9.0g                 
stayshare       float   %9.0g                 
topstayshare    float   %9.0g                 
lowgovsize      float   %9.0g                 
cid             float   %9.0g                 group(country year_gov)
proportionality float   %9.0g                 
norepresentat~n float   %9.0g                 
largestgroup    float   %9.0g                 
id              float   %9.0g                 group(country)
idd             float   %9.0g                 group(ethnicgroup country)
popshare2       float   %9.0g                 
coalitionmember float   %9.0g                 
------------------------------------------------------------------------------------------------------------------
Sorted by: country  year_gov  ethnicgroup

.  sort govshare;

. gen seats=.;
(11,749 missing values generated)

. replace seats=_n/100 if _n<101;
(100 real changes made)

. gen ports=.;
(11,749 missing values generated)

. replace ports=_n/100 if _n<101;
(100 real changes made)

. scatter govshare popshare if leadergroup==0, msymbol(Oh) mcolor(eltblue) msize(vtiny) 
>             || scatter govshare popshare if leadergroup==1, msymbol(O) mcolor(red) msize(vtiny)
>             || line govshare govshare if popshare<0.5, lcolor(black) clpattern(solid)
>             legend(col(1) size(2.5) region(lstyle(color(white))) order(2 1) position(5) ring(0) label(1 "{stSeri
> f:Not Leader's Ethnic Group}") label(2 "{stSerif:Leader's Ethnic Group}"))
>             ||,
>             xtitle("{stSerif:Ethnic Group Share of Population}", size(3) height(7)) 
>             ytitle("{stSerif:Ethnic Group Share of Cabinet Portfolios}" , size(3) height(7))
>             xlabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5))
>             ylabel(0 0.2 0.4 0.6 0.8 1.0 , nogrid labsize(2.5)) 
>             scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));

.                graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\ethnic.eps", replace;
(file C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\ethnic.eps written in EPS format)

. sum govshare popshare;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    govshare |     11,749    .0541041    .0831472          0   .8823529
    popshare |     11,749    .0543876    .0624053       .004        .39

. sum govshare popshare if leadergroup==0;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    govshare |     11,029    .0441514    .0652749          0   .4642857
    popshare |     11,029    .0504961    .0584153       .004        .39

. sum govshare popshare if leadergroup==1;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    govshare |        720     .206561    .1510445   .0064103   .8823529
    popshare |        720    .1139978    .0866208     .00515       .305

. gen error = abs(govshare-popshare);

. egen sum_error = sum(error);

. gen average_error=sum_error/11749;

. sum average_error;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
average_er~r |     11,749    .0380799           0   .0380799   .0380799

. gen error2 = abs(govshare-popshare) if leadergroup==1;
(11,029 missing values generated)

. egen sum_error2 = sum(error2);

. gen average_error2=sum_error2/720;

. sum average_error2;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
average_er~2 |     11,749    .1023248           0   .1023248   .1023248

. log close;
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure4.log
  log type:  text
 closed on:  30 Mar 2017, 13:56:08
------------------------------------------------------------------------------------------------------------------
